package com.scs.application.core.query;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * 排序条件
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class OrderCondition implements Serializable {

    private static final long serialVersionUID = 4740166316629191651L;

    private String field;
    private String rule;

    public void setRule(String rule) {
        if ("descending".equalsIgnoreCase(rule)) {
            rule = "desc";
        } else if ("ascending".equalsIgnoreCase(rule)) {
            rule = "asc";
        }

        this.rule = rule;
    }
}
